<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon-precomposed" href="../images/apple-touch-icon.png">
    <title>charts-bar</title>
    <link rel="stylesheet" href="../scripts/lib/seedsui/seedsui.min.css">
</head>
<body>
    <header>
        <div class="titlebar">
            <a class="titlebar-button" href="javascript:back()"><i class="size16 icon icon-arrowleft"></i></a>
            <h1 class="titlebar-title">柱状图</h1>
        </div>
    </header>
    <article>
	   <div id="ID-ChartBar" style="width: 100%;height:300px;"></div>
    </article>
	<script src="../scripts/lib/seedsui/seedsui.min.js"></script>
	<script src="../scripts/lib/echarts/echarts.min.js"></script>
    <!--Exmobi能力-->
    <!--<script src="../scripts/lib/exmobi/exmobi.js"></script>-->
    <script>
        var view={
            /*=========================
              Model
              ===========================*/
            initialize:function(){
                /*DOM*/
                /*Data*/
                //数据
                this.chartBarData=[
                    {value:"65",name:"1月份"},
                    {value:"18",name:"2月"},
                    {value:"78",name:"3月"},
                    {value:"12",name:"4月"},
                    {value:"95",name:"5月"},
                    {value:"23",name:"6月"},
                    {value:"88",name:"7月"},
                ];
                //提示信息
                this.chartBarTip="{b} : {c}";//{a}: series[].name ,{b}: series[].data[].name , {c}: series[].data[].value ,{d}: 占比

                /*或者用回调的方式
                function(params){
                    console.log(params);
                    return params.data.name+":"+params.value;
                },*/
                //x轴数据
                this.chartBarXAxisData=[];
                for(var i=0,cb;cb=this.chartBarData[i++];){
                    this.chartBarXAxisData.push(cb.name);
                }
                //色轮
                this.colorList=['#53c6fd','#ffae02','#3ae3ea','#ff6f36','#cf7af3','#4cd32e','#4587f7','#00c2eb','#ff618f','#21d9a1'];
                /*Plugin*/
                this.chartBarId="ID-ChartBar",this.chartBarOption,this.chartBar={};
            },
            /*=========================
              Method
              ===========================*/
            _initChartBar:function(){
                var self=this;
            	this.chartBar = echarts.init(document.getElementById(this.chartBarId));
            	this.chartBarOption = {
                    /*提示*/
            		tooltip : {
                        trigger: 'item',//触发类型，可选为：'axis' | 'item'
                        triggerOn:'click',
                        formatter: self.chartBarTip,
                        //当触发类型为axis，可设置此项
                        axisPointer : {// 坐标轴指示器，坐标轴触发有效
                            type : 'shadow',// 默认为直线，可选为：'line' | 'shadow'
                            shadowStyle:{
                                opacity:0
                            }
                        }
                    },
                    /*容器*/
            		grid : {
            			top:20,
                        left:50,
                        right:20,
                        bottom:50
            		},
                    /*x轴*/
            		xAxis : {
            			data : this.chartBarXAxisData,
                        axisLabel:{//文字
                            show:true,
                            textStyle :{
                                color:'#707070'
                            },
                        },
                        splitLine : {//分割线
                            show:true,
                            lineStyle: {
                                color: ['#ddd', '#ddd']// 使用深浅的间隔色
                            },
                        },
                        axisLine : {//轴线
                            show:true,
                            lineStyle: {
                                color: ['#cfcfcf']
                            }
                        },
                        axisTick : {//刻度线
                            show:true,
                            lineStyle: {
                                color: ['#ddd']
                            }
                        },
            		},
                    /*y轴*/
                    yAxis : {
                        axisLabel:{//文字
                            show:true,
                            textStyle :{
                                color:'#666666'
                            },
                        },
                        splitLine : {//分割线
                            show:true,
                            lineStyle: {
                                color: ['#ddd', '#ddd']// 使用深浅的间隔色
                            },
                        },
                        axisLine : {//轴线
                            show:true,
                            lineStyle: {
                                color: ['#adadad']
                            }
                        },
                        axisTick : {//刻度线
                            show:true,
                            lineStyle: {
                                color: ['#ddd']
                            }
                        },
                    },
                    /*系列*/
                    series : [
                    {
                        name:"月",
                        type:"bar",
                        itemStyle: {//type为bar时,设置柱的颜色
                            normal: {
                                color: function(params) {
                                    return self.colorList[params.dataIndex];
                                }
                            }
                        },
                        lineStyle:{//type为line时,设置线的颜色
                            normal: {
                                color: '#4bc0c0'
                            }
                        },
                        data : this.chartBarData
                    }
                    ]
            	}
            	this.chartBar.setOption(this.chartBarOption);
            },
            /*=========================
              Plugin
              ===========================*/
            _initPlugin:function(){
            	this._initChartBar();
            },
            /*=========================
              Events
              ===========================*/
            _attach:function(e){
                var self=this;
            },
            /*=========================
              Event Handler
              ===========================*/
            /*=========================
              OnLoad
              ===========================*/
            _onLoad:function(){
                var self=this;
                //DOM

                //Plugin
                this._initPlugin();
                //Events
                this._attach();
            }
        }

        window.addEventListener("load",function(){
            view._onLoad();
        }, false);

        document.addEventListener("DOMContentLoaded",function(){
            view.initialize();
        }, false);

        //定义exmobi返回
        function back(){history.go(-1);}
    </script>
</body>
</html>